package com.inno.subject.infra.basic.service.impl;

import com.github.pagehelper.Page;
import com.inno.subject.infra.basic.entity.PlannerSubjectCollect;
import com.inno.subject.infra.basic.mapper.PlannerSubjectCollectDao;
import com.inno.subject.infra.basic.service.PlannerSubjectCollectService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;


/**
 * 题目收藏信息表(PlannerSubjectCollect)表服务实现类
 *
 * @author makejava
 * @since 2024-11-22 13:52:09
 */
@Service("plannerSubjectCollectService")
public class PlannerSubjectCollectServiceImpl implements PlannerSubjectCollectService {
    @Resource
    private PlannerSubjectCollectDao plannerSubjectCollectDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PlannerSubjectCollect queryById(Long id) {
        return this.plannerSubjectCollectDao.queryById(id);
    }



    /**
     * 新增数据
     *
     * @param plannerSubjectCollect 实例对象
     * @return 实例对象
     */
    @Override
    public PlannerSubjectCollect insert(PlannerSubjectCollect plannerSubjectCollect) {
        this.plannerSubjectCollectDao.insert(plannerSubjectCollect);
        return plannerSubjectCollect;
    }

    /**
     * 修改数据
     *
     * @param plannerSubjectCollect 实例对象
     * @return 实例对象
     */
    @Override
    public PlannerSubjectCollect update(PlannerSubjectCollect plannerSubjectCollect) {
        this.plannerSubjectCollectDao.update(plannerSubjectCollect);
        return this.queryById(plannerSubjectCollect.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.plannerSubjectCollectDao.deleteById(id) > 0;
    }

    @Override
    public Page<PlannerSubjectCollect> queryPage(PlannerSubjectCollect plannerSubjectCollect) {
        return this.plannerSubjectCollectDao.queryPage(plannerSubjectCollect);
    }

    @Override
    public Long queryCollectCountBySubjectId(Long subjectId) {
        return this.plannerSubjectCollectDao.queryCountBySubjectId(subjectId);
    }

    @Override
    public PlannerSubjectCollect queryBySubjectIdAndUserId(PlannerSubjectCollect plannerSubjectCollect) {
        return this.plannerSubjectCollectDao.queryBySubjectIdAndUserId(plannerSubjectCollect);
    }

    @Override
    public List<PlannerSubjectCollect> queryBySubjectIdsAndUserId(Set<Long> subjectIdList, Long currentUser) {
        return this.plannerSubjectCollectDao.queryBySubjectIdsAndUserId(subjectIdList,currentUser);
    }


}
